Skip to content

Comments

Introduce clang-format#2684

Merged
MrAlias merged 5 commits intoopen-telemetry:mainfrom
rafaelroquetto:clang-format
Sep 8, 2025
Merged

Introduce clang-format#2684
MrAlias merged 5 commits intoopen-telemetry:mainfrom
rafaelroquetto:clang-format

Conversation

@rafaelroquetto
Copy link
Contributor

@rafaelroquetto rafaelroquetto commented Aug 19, 2025

Resolve #2288

Introduce clang-format to ensure all C code complies to the same formatting.

Namely, this PR brings:

  • a default .clang-format configuration (same as OBI)
  • a Makefile target - clang-format that will format all files
  • a convenience pre-commit hook that can be installed with make install-hooks - once installed, it will take care of formatting any C source code according to .clang-format before finalising the commit
  • a github workflow that will nag you if your C files are not properly formatted

Note: I've formatted all .C files in the tree accordingly. We might want to discuss that before this PR is merged.

@rafaelroquetto rafaelroquetto requested a review from a team as a code owner August 19, 2025 00:30
@rafaelroquetto
Copy link
Contributor Author

Looks like the clang-format workflow is working ;)

@rafaelroquetto
Copy link
Contributor Author

@MrAlias should this be part of the changelog?

@MrAlias
Copy link
Contributor

MrAlias commented Aug 19, 2025

@MrAlias should this be part of the changelog?

I don't think so. I've update with the "Skip Changelog" label.

@MrAlias MrAlias added this to the v0.23.0 milestone Aug 19, 2025
@rafaelroquetto
Copy link
Contributor Author

@MrAlias I did some research, and I think it will be difficult to ditch the explicit reference to clang-format-19, at least for now. If we want to be 100% consistent, we have to lock to a version because there were/are bugs affecting different major clang-format versions when it comes to the parsing of macros that are impossible to workaround only by manipulating the configuration file.

For instance: llvm/llvm-project#100304

It looks like something that has been fixed on clang-format-20 and this is why we see different outcomes.

@MrAlias MrAlias merged commit 5711c8e into open-telemetry:main Sep 8, 2025
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize our C formatting

2 participants